package com.hexinfo.dmpro.sparing.dto;

import com.hexinfo.dmpro.sparing.model.HdfsHeatBackup;
import com.hexinfo.dmpro.sparing.model.UatSyncLogsTask;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 每个表的hdfs相关信息
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TableDistCPDTO {

    //同步的源名
    private String sourceDataName;
    //源库名
    private String dbName;
    //源表名
    private String tableName;
    //备份库
    private String dbNameBack;
    //备份表
    private String tableNameBack;
    //目标库
    private String dbNameTar;
    //目标表
    private String tableNameTar;
    //获取上次热备Data
    private Date date;
    //比对sql对象
    private List<WhereScriptDTO> whereScriptDTOS;
    //符合要求的分区名,有无表示表有没有分区字段
    private String pkeyName;
    //同步范围 同步多久时间的数据 0为全量 数值为年数
    private Integer syncRange;
    //需要热备的文件总大小
    private Long hdfsFileSize;
    //表日志的存储路径
    private String logPath;
    //到表的hdfs路径
    private String tableHdfsPath;
    //每个表的hdfs路径
    private List<HdfsHeatBackup> hdfsHeatBackups;
    //hdfs路径初始数量
    private int tbHdfsNum;
    //表级日志分析记录id
    private String tableId;
    //任务信息
    private UatSyncLogsTask uatSyncLogsTask;

    //源库.表
    public String getDbTableName(){
        return dbName + "." + tableName;
    }

    //备份库.表
    public String getBackupName(){
        return dbNameBack + "." + tableNameBack;
    }

    //目标库.表
    public String getTargetName(){
        return dbNameTar + "." + tableNameTar;
    }

    //源_库_表
    public String getName(){
        return sourceDataName + "_" + dbName + "_" + tableName;
    }

    //源.库.表
    public String getSouDbTbName(){
        return sourceDataName + "." + dbName + "." + tableName;
    }

    //目标源_库_表
    public String getTarName(){
        return sourceDataName + "_" + dbNameTar + "_" + tableNameTar;
    }

}
